﻿/// File: ViewletControls\panel.fs
/// 
/// Author: Giacomo Righetti (righetti@di.unipi.it)
///   
/// ------------------------------------------------------------
/// Copyright (c) Microsoft Corporation.  All rights reserved.
/// 
/// The use and distribution terms for this software are 
/// contained in the file named license.txt, which can be found 
/// in the root of this distribution.
/// By using this software in any fashion, you are agreeing to 
/// be bound by the terms of this license.
///
/// You must not remove this notice, or any other, from this
/// software.
/// ------------------------------------------------------------

namespace LightweightControls

open System.Drawing
open System.Windows.Forms

///
/// Summary:
///     The lightweight version of the panel control.
type LightweightPanel() = 
    inherit LightweightControl()
    
    let mutable borderStyle = Border3DStyle.Sunken
    
    ///
    /// Summary:
    ///     Gets or sets the border style for the control.
    ///
    /// Returns:
    ///     One of the System.Windows.Forms.Border3DStyle values. The default is Border3DStyle.Sunken.
    member x.BorderStyle
        with get() = borderStyle
        and set(value) = 
            if value = Border3DStyle.Adjust then raise (System.ArgumentException("Style not supported"))
            borderStyle <- value; x.Invalidate()
    
    override x.IsContainer = true
    
    override x.TabStop = false
    
    override x.OnPaint(e) = 
        let g = e.Graphics
        use brush = new SolidBrush(x.BackColor)
        g.FillRectangle(brush, x.ClientRectangle)       
        ControlPaint.DrawBorder3D(g, x.ClientRectangle, borderStyle)